/*
 * @Author: your name
 * @Date: 2021-02-02 09:56:45
 * @LastEditTime: 2021-02-26 13:28:20
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \myproject\src\store\index.js
 */
import Vue from 'vue'
import Vuex from 'vuex'
import { setToken, getToken, removeToken } from '@/utils/ls.js'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // tokenInfo: {}
    tokenInfo: getToken() || {},
    userInfo: {}
  },
  mutations: {
    setToken (state, tokenObj) {
      state.tokenInfo = tokenObj
      setToken(tokenObj)
    },
    clearToken (state) {
      state.tokenInfo = {}
      removeToken()
    },
    setUserInfo (state, payload) {
      state.userInfo = payload
    }

  },
  actions: {
  },
  modules: {
  }
})
